//订单查询
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            sendStoreOrderCartInfo: {
                orderId:'',
                username: '',
                tel: '',
                address: '',
                solCompany: '',
                solNum:'',
                remark:'',
                sendWay:'SEFT',
                solCompanys: []
            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {
            vc.on('sendStoreOrderCart', 'openSendStoreOrderCartModel', function (_param) {
                $that.clearSendStoreOrderCart();
                vc.copyObject(_param, $that.sendStoreOrderCartInfo);
                $that._loadStoreOrderAddress();
                vc.getDict('store_order_logistics', "sol_company", function (_data) {
                    $that.sendStoreOrderCartInfo.solCompanys = _data;
                });
                $("#sendStoreOrderCartModal").modal('show');
            });
        },
        methods: {
            _loadStoreOrderAddress: function () { //发货方法
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        orderId: $that.sendStoreOrderCartInfo.orderId,
                        shopId:vc.getCurrentCommunity().shopId
                    }
                };
                //发送get请求
                vc.http.apiGet('/storeOrder.queryStoreOrderAddress',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.sendStoreOrderCartInfo);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            clearSendStoreOrderCart: function () {
                $that.sendStoreOrderCartInfo = {
                    orderId:'',
                    username: '',
                    tel: '',
                    address: '',
                    solCompany: '',
                    solNum:'',
                    remark:'',
                    sendWay:'SEFT',
                    solCompanys: []
                }
            },
            _closeStoreOrderCartModal: function () {
                $("#sendStoreOrderCartModal").modal('hide');
            },
            _sendOrderCart: function () {
                $that.sendStoreOrderCartInfo.shopId=vc.getCurrentCommunity().shopId;
                //发送get请求
                vc.http.apiPost('/storeOrder.sendStoreOrderCart',
                    JSON.stringify($that.sendStoreOrderCartInfo), {
                    emulateJSON: true
                },
                    function (json, res) {
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            $that._closeStoreOrderCartModal();
                            vc.emit('storeOrderCart', 'list', {});
                            vc.toast('发货成功');
                            return;
                        }
                        vc.toast(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },

        }
    });
})(window.vc);